<ul class="flex flex-col">
  <% menu_items.each do |menu_item|
      sub_menu = menu_item[:sub_menu] || []
      link_active_class= "text-base-content"
      text_class = ""
      if sub_menu.empty?
        if controller_name.to_sym == menu_item[:main_controller].to_sym
          if menu_item[:action_name].blank? || (action_name.to_sym == menu_item[:action_name].to_sym)
            link_active_class = "border-r-2 text-primary bg-base-100"
          end
        end
      else
        sub_menu.each do |menu_item|
          if controller_name.to_sym == menu_item[:main_controller].to_sym
            link_active_class = "bg-base-100"
          end
        end
      end
  %>
      <li class="relative group">
        <%
          wrapper_options = {
            "class": "block px-8 py-4 #{link_active_class} hover:border-r-2 border-primary hover:bg-base-100 hover:text-primary truncate transition duration-150",
            href: menu_item[:url]
          }

        %>
        <%= content_tag(:a, wrapper_options) do %>
          <div class="flex  flex-col justify-between gap-2">
            <div class="flex items-center text-lg">

              <span class=" group-hover:text-primary">
                <%= menu_item[:icon] %>
              </span>
              <span class="group-hover:text-primary group-hover:font-bold group-active:text-primary text-sm font-medium ml-4 md:hidden md:sidebar-expanded:block"><%= menu_item[:text] %></span>
            </div>
          </div>
        <% end %>
        <% if menu_item[:hover_menu] %>
          <div class="hidden group-hover:flex w-max flex-col border border-primary bg-background-menu absolute top-0 left-[100%] rounded-sm">
            <%  menu_item[:hover_menu].each do |menu_item| %>
              <%= link_to menu_item[:text], menu_item[:url],
                class: "text-sm font-medium text-base-content p-4 pr-8 hover:bg-primary hover:text-primary" %>
            <% end %>
          </div>
        <% end %>
      </li>

  <% end %>

</ul>